﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace Home.Domain.Entities
{
    //EF Code First需要创建的模型
    public class EFDbContext : DbContext
    {
        private readonly static string CONNECTION_STRING = "name=db";
        public EFDbContext()
            : base(CONNECTION_STRING)
        {
            base.Configuration.ValidateOnSaveEnabled = false;//获取或设置一个值，该值指示是否跟踪的实体应验证自动调用 System.Data.Entity.DbContext.SaveChanges() 时。默认值为 true。
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();//生成的表名不加s
            modelBuilder.Configurations.Add(new Example.UserInfoMap());
            modelBuilder.Configurations.Add(new Secondary.Mapping.TPCUserInfoMap());
            //#region 不映射
            //modelBuilder.Ignore<Secondary.TPCUserInfo>(); 
            //#endregion
        }
        /// <summary>
        /// 公司简介
        /// </summary>
        public DbSet<Company> Companys { get; set; }
        public DbSet<News> News { get; set; }
        public DbSet<PNews> PNews { get; set; }
        public DbSet<Example.UserInfo> EUserInfos { get; set; }
        /// <summary>
        /// 分类
        /// </summary>
        public DbSet<Category> Categorys { get; set; }
        /// <summary>
        /// 品牌
        /// </summary>
        public DbSet<Brand> Brands { get; set; }
        public DbSet<Category_Brand> Category_Brands { get; set; }
        public DbSet<Quote> Quotes { get; set; }
        public DbSet<QuoteProduct> QuoteProducts { get; set; }
        public DbSet<Product> Products { get; set; }
        public DbSet<ProductPrice> ProductPrices { get; set; }
        public DbSet<Salesman> Salesmans { get; set; }
    }
}
